﻿@using KRM.Core
@model tblKRMTradeCustomer
@{
    var priceList = new KRMEntities().vCurrentProductAlias.Where(a => a.TradeAccNumber == Model.TradeAccNumber).ToList();
}
<div class="row-fluid">
    <fieldset class="margin0">
        <legend>Search For Kybotech Products</legend>
        <form action="/trade/tradesearchproductkybotech" method="POST" class="margin0" id="fr-tradesearchproduct">
            <div class="row-fluid">
                <div class="span1">ProductID</div>
                <div class="span3">
                    <input type="text" class="input-block-level" name="productid" />
                </div>
                <div class="span2 text-right">Product Name</div>
                <div class="span4">
                    <input type="text" class="input-block-level" name="productname" />
                </div>
                <div class="span2">
                    <input class="btn btn-primary" value="Search for product" type="submit" />
                </div>
            </div>
        </form>
        <div class="row-fluid">
            <div class="span4">
                <div class="row-fluid">
                    <select class="input-block-level" multiple="multiple" style="height: 334px; margin: 0" id="lstproductresult" onchange="tradeproductselected(this.value, '0')"></select>
                </div>
            </div>
            <div class="span8">
                <form action="/trade/createproductalias" method="POST" class="margin0 border-padding10" id="fr-createproductalias">
                    <input type="hidden" name="productid" id="hfproductid" />
                    <input type="hidden" name="accNumber" value="@(Model != null ? Model.TradeAccNumber : 0)"/>
                    <div id="pnTradeproductdetail"></div>
                </form>
            </div>
        </div>


    </fieldset>
</div>

<div class="row-fluid">
    <div class="fieldset" style="margin-top: 10px">
        <div class="legend"><span>Current Product Alias</span></div>
        <form action="/trade/CurrentProductPriceList" class="margin0" id="fr-currentproductalias" method="GET">
            <input type="hidden" name="accNumber" value="@(Model != null ? Model.TradeAccNumber : 0)"/>
            <div class="row-fluid">
                <div class="span2">Trade Code</div>
                <div class="span3">
                    <input type="text" class="input-block-level" name="tradecode" />
                </div>
                <div class="span2">Trade Barcode</div>
                <div class="span3">
                    <input type="text" class="input-block-level" name="tradebarcode" />
                </div>
                <div class="span2">
                    <input type="submit" value="Search" class="btn btn-primary" />
                </div>
            </div>
        </form>
        <div class="tblproductalias">
            <table class="table table-bordered table-fix tbl-selected">
                <thead>
                    <tr>
                        <th>Id</th>
                        <th>Code</th>
                        <th>Product</th>
                        <th>Option</th>
                        <th>SubOptions</th>
                        <th>TradeBarcode</th>
                        <th>TradePrice</th>
                        <th>Margin(£)</th>
                        <th>Margin(%)</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var item in priceList)
                    {
                        <tr onclick="currentproductpriceselected('@item.ID','@Model.TradeAccNumber', '@item.ProductID')">
                            <td>@item.ID</td>
                            <td>@item.ProductCode</td>
                            <td>@item.ProductName</td>
                            <td>@item.ProductOptionText</td>
                            <td>@item.SubOptionsListString</td>
                            <td>@item.TradeBarcode</td>
                            <td>@item.TradeOptionPrice.ToString("N2")</td>
                            <td>@((item.MarginPounds ?? 0).ToString("N2"))</td>
                            <td>@((item.MarginPercent ?? 0).ToString("N2"))</td>
                        </tr>
                    }
                </tbody>
            </table>
        </div>
        <div class="text-right">
            <input type="button" value="Delete Selected" class="btn btn-danger btn-deletecurrentproductprice" onclick="deletecurrentproductprice('0', '0')" />
        </div>
    </div>
</div>
